﻿namespace 工厂模式
{
    /// <summary>
    /// 抽象工厂
    /// </summary>
    //工厂模式的进一步优化，提取出工厂接口，不同的水果工厂实现这个接口
    public interface IFactory
    {
        Fruit Create();
    }

    //苹果工厂
    internal class AppleFactory : IFactory
    {
        public Fruit Create()
        {
            return new Apple();
        }
    }

    //梨子工厂
    internal class PearFactory : IFactory
    {
        public Fruit Create()
        {
            return new Pear();
        }
    }

    //香蕉工厂
    internal class BananaFactory : IFactory
    {
        public Fruit Create()
        {
            return new Banana();
        }
    }
}